<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        let ary = [1, 2, 3, 1, 2, 1, 2, 3, 2, 1, 2, 3]
        //1.创建一个空对象
        let obj = {}
        //2.循环数组中的每一项，把每一项向对象中进行存储=>item:item
        for (let i = 0; i < ary.length; i++) {
            let item = ary[i]
            //3.每一次存储之前进行判断：验证obj是否存在这一项
            if (obj[item] === item) {
                //已经存在这一项,把他删掉
                ary.splice(i, 1)
                i--

            } else {
                obj[item] = item
            }

        }
        console.log(obj);
        //基于splice实现删除性能不好，当前项删除后，后面每一项的索引都要向前提一位，如果后面内容过多，一定影响性能
    </script>
</body>

</html>